home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / jstree.h.z / jstree.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  7.2 KB  |  329 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Torben Weis (weis@kde.org)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.     Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef JSTREE_H
  20. #define JSTREE_H
  21.  
  22. class JSValue;
  23. class JSNode;
  24. class JSScope;
  25. class JSScopeStack;
  26. class JSFunction;
  27. class JSParameter;
  28. class JSFunctionCall;
  29. class JSConstructorCall;
  30. class JSArgument;
  31. class JSParameterListObject;
  32. class JSThis;
  33. class JSStringObject;
  34. class JSArrayaAccess;
  35.  
  36. #include <qstring.h>
  37.  
  38. #define ID_JSNode 1
  39. #define ID_JSInteger 2
  40. #define ID_JSBinaryOperator 3
  41. #define ID_JSAssignment 4
  42. #define ID_JSIdentifier 5
  43. #define ID_JSStatement 6
  44. #define ID_JSFunction 7
  45. #define ID_JSParameter 8
  46. #define ID_JSFunctionCall 9
  47. #define ID_JSArgument 10
  48. #define ID_JSConstructorCall 11
  49. #define ID_JSThis 12
  50. #define ID_JSMember 13
  51. #define ID_JSString 14
  52. #define ID_JSBool 15
  53. #define ID_JSFloat 16
  54. #define ID_JSNull 17
  55. #define ID_JSArrayAccess 18
  56.  
  57. class JSNode
  58. {
  59. public:
  60.     JSNode();
  61.     virtual ~JSNode() { }
  62.     
  63.     virtual int isA() { return ID_JSNode; }
  64.  
  65.     virtual int leftValue( JSScopeStack* _s, JSValue *lv );
  66.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  67. };
  68.  
  69. #include "jsexec.h"
  70.  
  71. class JSStatement : public JSNode
  72. {
  73. public:
  74.     JSStatement( JSNode *_code, JSNode *_next_code );
  75.     virtual ~JSStatement() { if ( code ) delete code; if ( nextCode ) delete nextCode; }
  76.     
  77.     virtual int isA() { return ID_JSStatement; }
  78.  
  79.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  80.  
  81. protected:
  82.     JSNode *code;
  83.     JSNode *nextCode;
  84. };
  85.  
  86. class JSInteger : public JSNode
  87. {
  88. public:
  89.     JSInteger( int );
  90.     virtual ~JSInteger() { }
  91.  
  92.     virtual int isA() { return ID_JSInteger; }
  93.  
  94.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  95.  
  96. protected:
  97.     int value;
  98. };
  99.  
  100. class JSBool : public JSNode
  101. {
  102. public:
  103.     JSBool( bool );
  104.     virtual ~JSBool() { }
  105.  
  106.     virtual int isA() { return ID_JSBool; }
  107.  
  108.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  109.  
  110. protected:
  111.     bool value;
  112. };
  113.  
  114. class JSFloat : public JSNode
  115. {
  116. public:
  117.     JSFloat( double );
  118.     virtual ~JSFloat() { }
  119.  
  120.     virtual int isA() { return ID_JSFloat; }
  121.  
  122.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  123.  
  124. protected:
  125.     double value;
  126. };
  127.  
  128. class JSBinaryOperator : public JSNode
  129. {
  130. public:
  131.     JSBinaryOperator( int _op, JSNode *_left, JSNode *_right );
  132.     virtual ~JSBinaryOperator() { if ( leftNode ) delete leftNode; if ( rightNode ) delete rightNode; }
  133.  
  134.     virtual int isA() { return ID_JSBinaryOperator; }
  135.  
  136.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  137.     
  138. protected:
  139.     int op;
  140.     JSNode *leftNode;
  141.     JSNode *rightNode;
  142. };
  143.  
  144. class JSAssignment : public JSBinaryOperator
  145. {
  146. public:
  147.     JSAssignment( int _op, JSNode *_left, JSNode *_right );
  148.     virtual ~JSAssignment() { }
  149.  
  150.     virtual int isA() { return ID_JSAssignment; }
  151.  
  152.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  153. };
  154.  
  155. class JSIdentifier : public JSNode
  156. {
  157. public:
  158.     JSIdentifier( const char *_name );
  159.     virtual ~JSIdentifier() { }
  160.  
  161.     virtual int isA() { return ID_JSIdentifier; }
  162.  
  163.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  164.     virtual int leftValue( JSScopeStack* _s, JSValue *rv );    
  165.  
  166. protected:
  167.     QString name;
  168. };
  169.  
  170. class JSFunction : public JSNode
  171. {
  172. public:
  173.     JSFunction( const char *_name, JSParameter* _param, JSNode *_code );
  174.     virtual ~JSFunction() { }
  175.  
  176.     virtual int isA() { return ID_JSFunction; }
  177.  
  178.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  179.     virtual int rightValue( JSScopeStack* _s, JSValue *rv, JSParameterListObject *_param );    
  180.  
  181.     const char* getName() { return name.data(); }
  182.     
  183. protected:
  184.     QString name;
  185.     JSNode *code;
  186.     JSParameter *parameters;
  187. };
  188.  
  189. class JSParameter : public JSNode
  190. {
  191. public:
  192.     /**
  193.      * JSParameter may be 0L to indicate that there are no parameters to this
  194.      * function.
  195.      */
  196.     JSParameter( const char *_name, JSParameter *_next );
  197.     virtual ~JSParameter() { }
  198.  
  199.     virtual int isA() { return ID_JSParameter; }
  200.  
  201.     JSParameter* getNextParameter() { return nextParameter; }
  202.     
  203. protected:
  204.     QString name;
  205.     JSParameter *nextParameter;
  206. };
  207.  
  208. class JSFunctionCall : public JSNode
  209. {
  210. public:
  211.     JSFunctionCall( JSNode *_function, JSArgument *_arguments );
  212.     virtual ~JSFunctionCall() { }
  213.     
  214.     virtual int isA() { return ID_JSFunctionCall; }
  215.  
  216.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  217.  
  218. protected:
  219.     JSNode *function;
  220.     JSArgument *arguments;
  221. };
  222.  
  223. class JSArgument : public JSNode
  224. {
  225. public:
  226.     JSArgument( JSNode *_code, JSArgument *_next );
  227.     virtual ~JSArgument() { }
  228.  
  229.     virtual int isA() { return ID_JSArgument; }
  230.  
  231.     virtual int rightValue( JSScopeStack *_scopes, JSParameterListObject *_param );
  232.  
  233.     JSArgument* getNextArgument() { return nextArgument; }
  234.     
  235. protected:
  236.     JSNode *code;
  237.     JSArgument *nextArgument;
  238. };
  239.  
  240. class JSConstructorCall : public JSNode
  241. {
  242. public:
  243.     JSConstructorCall( JSNode *_function, JSArgument *_arguments );
  244.     virtual ~JSConstructorCall() { }
  245.     
  246.     virtual int isA() { return ID_JSConstructorCall; }
  247.  
  248.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  249.  
  250. protected:
  251.     JSNode *function;
  252.     JSArgument *arguments;
  253. };
  254.  
  255. class JSThis : public JSNode
  256. {
  257. public:
  258.     JSThis();
  259.     virtual ~JSThis() { }
  260.     
  261.     virtual int isA() { return ID_JSThis; }
  262.  
  263.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  264. };
  265.  
  266. class JSMember : public JSNode
  267. {
  268. public:
  269.     JSMember( JSNode *_obj, const char *_name );
  270.     virtual ~JSMember();
  271.     
  272.     virtual int isA() { return ID_JSMember; }
  273.  
  274.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  275.     virtual int leftValue( JSScopeStack* _s, JSValue *lv );
  276.  
  277. protected:
  278.     QString name;
  279.     JSNode *object;
  280. };
  281.  
  282. class JSString : public JSNode
  283. {
  284. public:
  285.     JSString( const char *_string );
  286.     virtual ~JSString();
  287.  
  288.     virtual int isA() { return ID_JSString; }
  289.  
  290.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  291.  
  292. protected:    
  293.     JSStringObject *object;
  294. };
  295.  
  296. class JSNull : public JSNode
  297. {
  298. public:
  299.     JSNull();
  300.     virtual ~JSNull();
  301.  
  302.     virtual int isA() { return ID_JSNull; }
  303.  
  304.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );
  305.  
  306. protected:    
  307.     JSObject *object;
  308. };
  309.  
  310. class JSArrayAccess : public JSNode
  311. {
  312. public:
  313.     JSArrayAccess( JSNode *_array, JSNode *_index );
  314.     virtual ~JSArrayAccess() { }
  315.  
  316.     virtual int isA() { return ID_JSArrayAccess; }
  317.  
  318.     virtual int rightValue( JSScopeStack* _s, JSValue *rv );    
  319.     virtual int leftValue( JSScopeStack* _s, JSValue *rv );    
  320.  
  321. protected:
  322.     JSNode *index;
  323.     JSNode *array;    
  324. };
  325.  
  326. #endif
  327.  
  328.  
  329.